package com.company.bilibili;

import java.util.Scanner;

public class Main3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println(GetCoinCount(n));

    }

    public static int GetCoinCount (int N) {
        // write code here
        int rest = 1024 - N;
        int[] dp = new int[rest + 1];
        dp[0] = 0;
        // 金币
        int[] coins = {1,4,16,64};
        for (int i = 1; i <= rest ; i++) {
            dp[i] = rest + 1;
            for (int coin:coins){
                if(i >= coin){
                    dp[i] = Math.min(dp[i - coin] + 1,dp[i]);
                }
            }
        }
        return dp[rest ];
    }
}
